'''Project Euler Problem 17

If the numbers 1 to 5 are written out in words: one, two, three, four, five,
then there are 3 + 3 + 5 + 4 + 4 = 19 letters used in total.

If all the numbers from 1 to 1000 (one thousand) inclusive were written out
in words, how many letters would be used?

NOTE: Do not count spaces or hyphens. For example, 342 (three hundred and
forty-two) contains 23 letters and 115 (one hundred and fifteen) contains 20
letters. The use of "and" when writing out numbers is in compliance with
British usage.

http://projecteuler.net/index.php?section=problems&id=17
'''

ones     = ['','one','two','three','four',
            'five','six','seven','eight','nine']
tens     = ['','','twenty','thirty','forty',
           'fifty','sixty','seventy','eighty','ninety']
teens    = ['ten','eleven','twelve','thirteen','fourteen',
            'fifteen','sixteen','seventeen','eighteen','nineteen']
hund     = 'hundred'

def inWords(num):
    words, onesnum, num = ones[num % 10], num % 10, int(num / 10)
    tensnum, num = num % 10, int(num / 10)
    if tensnum == 1:
        words = teens[onesnum]
    else:
        words = tens[tensnum] + words
        
    if 0 < num <= 9:
        if words:
            words = ones[num % 10] + hund + 'and' + words
        else:
            words = ones[num % 10] + hund
        num = int(num / 10)
    elif num == 10:
        words = 'onethousand' + words
    return words    

oneslen  = [len(s) for s in ones]
tenslen  = [len(s) for s in tens]
teenslen = [len(s) for s in teens]
hundlen  = [len(s) for s in hund]
def inWordsLen(num):
    pass

lottawords = ''
for i in range(1,1001): lottawords += inWords(i)

print 'The answer to Problem #17 is >> %i <<' % len(lottawords)